package com.yunkeji.api.user.controller;

import com.yunkeji.api.user.service.AppUserBlackService;
import com.yunkeji.api.user.vo.BlackListVo;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.PageQuery;
import com.yunkeji.common.core.domain.R;
import com.yunkeji.common.core.page.TableDataInfo;
import com.yunkeji.dao.domain.BaseId;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 用户相关接口-黑名单
 *
 * @author 老张
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/user")
public class AppUserBlackController extends BaseController {

    private final AppUserBlackService appUserBlackService;

    /**
     * 我的黑名单
     *
     * @author 老张
     */
    @PostMapping("/blackList")
    public TableDataInfo<BlackListVo> blackList(@RequestBody PageQuery pageQuery) {
        return appUserBlackService.blackList(pageQuery);
    }
    /**
     * 解封黑名单
     *
     * @author 老张
     */
    @PostMapping("/removeBlack")
    public R<Void> removeBlack(@Valid @RequestBody BaseId baseId) {
        appUserBlackService.removeBlack(baseId);
        return R.ok();
    }

    /**
     * 加入黑名单
     *
     * @author 老张
     */
    @PostMapping("/addBlack")
    public R<Void> addBlack(@Valid @RequestBody BaseId baseId) {
        appUserBlackService.addBlack(baseId);
        return R.ok();
    }
}
